package com.sc.VenusQueryBeta.presenter.account.xiazhuanma;


import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.sc.VenusQueryBeta.contract.account.xiazhuanma.XiaZhuanMaContract;
import com.sc.VenusQueryBeta.model.account.xiazhuanma.XiaZhuanMaModel;
import com.sc.VenusQueryBeta.model.bean.account.AccountList;
import com.sc.VenusQueryBeta.model.bean.account.AllRoomListBean;
import com.sc.VenusQueryBeta.model.bean.account.CurrencyListBean;
import com.sc.VenusQueryBeta.model.bean.account.MaxChangemonthBean;

import io.reactivex.functions.Consumer;

/**
 * Created by SC-02 on 2018/9/19.
 * 线下转码明细presenter 继承契约类的presenper
 */

public class XiaZhuanMaPresenter extends XiaZhuanMaContract.XiaZhuanMaPresenter{
    @Override
    protected XiaZhuanMaContract.IXiaZhuanMaModel getModel() {
        return XiaZhuanMaModel.newInstance();
    }

    @Override
    public void onStart() {

    }

    /**
     *实例化对象
     */
    public static XiaZhuanMaPresenter newInstance(){
        return new XiaZhuanMaPresenter();
    }

//    /**
//     * 查询厅
//     * @param serverAddress
//     * @param projectName
//     * @param serverPort
//     */
//    @Override
//    public void queryAllRoomList(String serverAddress, String projectName, int serverPort) {
//        if (mIView == null || mIModel == null)
//            return;
//        mRxManager.register(mIModel.queryAllRoomList(serverAddress,projectName,serverPort).subscribe(new Consumer<AllRoomListBean>() {
//            @Override
//            public void accept(AllRoomListBean allRoomListBean) throws Exception {
//                mIView.showqueryAllRoomList(allRoomListBean);
//            }
//        }, new Consumer<Throwable>() {
//            @Override
//            public void accept(Throwable throwable) throws Exception {
//                LogUtils.e("Network error."+throwable.getMessage());
//                mIView.showToast("Network error.");
//                mIView.showAllRoomNetworkError(throwable);
//            }
//        }));
//    }

//    /**
//     * 查询子户口
//     * @param serverAddress
//     * @param projectName
//     * @param serverPort
//     * @param clientindex
//     * @param roomid
//     * @param roomyear
//     * @param roommonth
//     * @param recognitionValue
//     * @param depositType
//     */
//    @Override
//    public void queryClientReserved02(String serverAddress, String projectName, int serverPort, int clientindex, int roomid, String roomyear, String roommonth, String recognitionValue, String depositType, int chiptype) {
//        if (mIView == null || mIModel == null)
//            return;
//        mRxManager.register(mIModel.queryZiHuList(serverAddress,projectName,serverPort,clientindex,roomid, roomyear,
//                roommonth,recognitionValue,depositType,chiptype).subscribe(new Consumer<AccountList>() {
//            @Override
//            public void accept(AccountList accountListBean) throws Exception {
//                mIView.showZiHuKouList(accountListBean);
//            }
//        }, new Consumer<Throwable>() {
//            @Override
//            public void accept(Throwable throwable) throws Exception {
//                LogUtils.e("错误查询子户口"+throwable.getMessage());
////                if (mIView != null)
////                    return;
//                mIView.showToast("Network error."+throwable.getMessage());
//                mIView.showNetworkError(throwable);
//            }
//        }));
//    }

//    /**
//     * 查询最大日期
//     * @param serverAddress
//     * @param projectName
//     * @param serverPort
//     * @param roomid
//     */
//    @Override
//    public void queryMaxChangemonth(String serverAddress, String projectName, int serverPort, int roomid) {
//        if (mIView == null || mIModel == null)
//            return;
//        mRxManager.register(mIModel.queryMaxChangemonth(serverAddress,projectName,serverPort,roomid).subscribe(new Consumer<MaxChangemonthBean>() {
//            @Override
//            public void accept(MaxChangemonthBean allRoomListBean) throws Exception {
//                mIView.showMaxChangemonthList(allRoomListBean);
//            }
//        }, new Consumer<Throwable>() {
//            @Override
//            public void accept(Throwable throwable) throws Exception {
//                LogUtils.e("Network error."+throwable.getMessage());
//                mIView.showToast("Network error."+throwable.getMessage());
//                mIView.showNetworkError(throwable);
//            }
//        }));
//    }

    @Override
    public void queryAllCurrencyList(String serverAddress, String projectName, int serverPort) {
        if (mIView == null || mIModel == null)
            return;
        mRxManager.register(mIModel.queryAllCurrencyList(serverAddress,projectName,serverPort).subscribe(new Consumer<CurrencyListBean>() {
            @Override
            public void accept(CurrencyListBean currencyListBean) throws Exception {
                mIView.showqueryAllCurrencyList(currencyListBean);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                LogUtils.e("Network error."+throwable.getMessage());
                mIView.showToast("Network error.");
                mIView.showAllCurrencyNetworkError(throwable);
            }
        }));
    }

    @Override
    public void queryClientReserved02(String serverAddress, String projectName, int serverPort, int clientindex, String roomyear, String roommonth, String recognitionValue, String depositType,String currencynameCN) {
        if (mIView == null || mIModel == null)
            return;
        mRxManager.register(mIModel.queryZiHuList(serverAddress,projectName,serverPort,clientindex, roomyear,
                roommonth,recognitionValue,depositType,currencynameCN).subscribe(new Consumer<AccountList>() {
            @Override
            public void accept(AccountList accountListBean) throws Exception {
                mIView.showZiHuKouList(accountListBean);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                LogUtils.e("错误查询子户口"+throwable.getMessage());
//                if (mIView != null)
//                    return;
                mIView.showToast("Network error."+throwable.getMessage());
                mIView.showNetworkError(throwable);
            }
        }));
    }
}
